package org.example.likou150;

import java.util.Arrays;


public class LengthOfLongestSubstring {
    public int lengthOfLongestSubstring(String s) {
        char[] charArray = s.toCharArray();
        int[] bloom = new int[128];
        Arrays.fill(bloom, -1);
        int left = 0;
        int longLen = 0;
        for (int i = 0; i < charArray.length; i++) {
            if(bloom[charArray[i]]!=-1){
                left = Math.max(left ,bloom[charArray[i]]+1);
            }
            bloom[charArray[i]] = i;
            longLen = Math.max(longLen, i-left+1);
        }
        return longLen;
    }
}
